package com.wc.alorithm_luogu._DFS.kkksc03考前临时抱佛脚;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2025/1/12 21:30
 * @description
 * https://www.luogu.com.cn/problem/P2392
 */
public class Main {
    /**
     * 思路：
     * 要么放在左边, 要么放在右边
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 25, INF = 0x3f3f3f3f;
    static int[] a = new int[N];
    static int[] b = new int[N];
    static int n, res = 0, tmp = 0;

    public static void main(String[] args) {
        for (int i = 1; i <= 4; i++) b[i] = sc.nextInt();
        for (int t = 1; t <= 4; t++) {
            n = b[t];
            for (int i = 1; i <= n; i++) a[i] = sc.nextInt();
            tmp = INF;
            dfs(1, 0, 0);
            res += tmp;
        }
        out.println(res);
        out.flush();
    }

    static void dfs(int u, int L, int R) {
        if (u == n + 1) {
            tmp = Math.min(tmp, Math.max(L, R));
            return;
        }
        // 放左边
        dfs(u + 1, L + a[u], R);
        // 放右边
        dfs(u + 1, L, R + a[u]);
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}

